package Jvm;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

/**
 * Created by kai on 2015/8/14 0014.
 */
public class TestUnsafe {
    public static void main(String[] args) throws IllegalAccessException {
        //获取unsafe的实例
        Field field = Unsafe.class.getDeclaredFields()[0];
        field.setAccessible(true);
        Unsafe unsafe = (Unsafe) field.get(null);
        unsafe.allocateMemory(1024l);

        //
        Field lockfield = Lock.class.getDeclaredFields()[0];
        lockfield.setAccessible(true);
        Lock l = (Lock) lockfield.get(null);
        l.say();

    }
}
